//
//  DSLeaderboardCell.m
//  DSJY
//
//  Created by 冯华强 on 16/9/24.
//  Copyright © 2016年 dsjy. All rights reserved.
//  排行榜

#import "DSLeaderboardCell.h"
#import "DSLeaderboardView.h"
#import "DSLearnScore.h"
#import "DSLearnInfoViewModel.h"
#import "MTConst.h"
#import "Masonry.h"

@interface DSLeaderboardCell ()
#pragma mark - 拖线属性
//今日成绩
@property (nonatomic, weak) DSLeaderboardView *todayView;
//本周成绩
@property (nonatomic, weak) DSLeaderboardView *monthView;
@end

@implementation DSLeaderboardCell

#pragma mark - 系统回调
- (void)awakeFromNib
{
    [super awakeFromNib];
    
    //设置UI
    [self setupView];
}

#pragma mark - 设置UI
- (void)setupView
{
    self.todayView = [self createLeaderboardView];
    self.monthView = [self createLeaderboardView];
    
    [self.todayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.top.bottom.mas_equalTo(0);
        make.right.equalTo(self.contentView.mas_right).multipliedBy(1.0/2.0);
    }];
    
    [self.monthView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.todayView.mas_right);
        make.top.bottom.mas_equalTo(0);
        make.width.equalTo(self.todayView);
    }];
}

- (DSLeaderboardView *)createLeaderboardView
{
    DSLeaderboardView *leaderboardView = [DSLeaderboardView leaderboardView];
    [self.contentView addSubview:leaderboardView];
    return leaderboardView;
}

- (void)setLearnInfoVM:(DSLearnInfoViewModel *)learnInfoVM
{
    _learnInfoVM = learnInfoVM;
    
    //今日
    self.todayView.indexPath = learnInfoVM.indexPath;
    self.todayView.learnInfo = learnInfoVM.todayLearnInfo;
   
    //月份
    self.monthView.indexPath = learnInfoVM.indexPath;
    self.monthView.learnInfo = learnInfoVM.monthLearnInfo;
}

@end
